package com.scproject.scbef.controller.study.politicsactivity;

import com.scproject.annotations.LoginVerifyToken;
import com.scproject.annotations.PassToken;
import com.scproject.dto.ResponseDto;
import com.scproject.scbef.pojo.PoliticsBuildActivity;
import com.scproject.scbef.service.study.politicsactivity.PoliticsActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LNL
 * @date 2021/5/23 10:20
 */
@RestController
@Api(tags = "党建活动模块")
@RequestMapping("/politics")
public class PoliticsActivityController {

    @Autowired
    private PoliticsActivityService politicsActivityService;

    @GetMapping("/activities")
    @ApiOperation("获取所有的党建活动")
    @PassToken
    public ResponseDto getAllPoliticsActivities() {
        ResponseDto responseDto = politicsActivityService.getAllActivities();
        return responseDto;
    }

    @ApiOperation("删除活动")
    @PostMapping("/delete/{id}")
    @LoginVerifyToken
    public ResponseDto deleteActivity(@PathVariable("id") String id) {
        ResponseDto responseDto = politicsActivityService.deleteActivity(id);
        return responseDto;
    }

    @ApiOperation("添加活动")
    @PostMapping("/insert")
    @LoginVerifyToken
    public ResponseDto insertActivity(MultipartHttpServletRequest request) {
        ResponseDto responseDto = politicsActivityService.insertActivity(request);
        return responseDto;
    }

    @ApiOperation("修改活动")
    @PostMapping("/update")
    @LoginVerifyToken
    public ResponseDto updateActivity(@RequestBody PoliticsBuildActivity politicsBuildActivity, HttpServletRequest request) {
        ResponseDto responseDto = politicsActivityService.updateActivity(politicsBuildActivity,request);
        return responseDto;
    }


}
